import createPersistedState from 'vuex-persistedstate'
import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        // 端口号和密钥
        storeKey: {},
        // 客户端状态
        storeClientStart: false,
        // 玩家状态   比如在大厅   寻找对局   游戏中
        storeUserState: '',
        // 玩家信息
        storeUserInfo: {},
        // 自动接收对局
        storeReadyValue: true,
        // 秒选英雄Id
        storeRoleValue: -1
    },
    getters: {
        getStoreKey(state) {
            return state.storeKey
        },
        getStoreClientStart(state) {
            return state.storeClientStart
        },
        getStoreUserState(state) {
            return state.storeUserState
        },
        getStoreUserInfo(state) {
            return state.storeUserInfo
        },
        getStoreReadyValue(state) {
            return state.storeReadyValue
        },
        getStoreRoleValue(state) {
            return state.storeRoleValue
        },
    },
    mutations: {
        setStoreKey: (state, data) => {
            state.storeKey = data
        },
        setStoreClientStart: (state, data) => {
            state.storeClientStart = data
        },
        setStoreUserState: (state, data) => {
            state.storeUserState = data
        },
        setStoreUserInfo: (state, data) => {
            state.storeUserInfo = data
        },
        setStoreReadyValue(state, data) {
            state.storeReadyValue = data
        },
        setStoreRoleValue(state, data) {
            state.storeRoleValue = data
        },
    },
    actions: {},
    modules: {},
    plugins: [createPersistedState()]
});